 package server.maps;

 import client.MapleCharacter;
 import client.MapleClient;
 import client.inventory.Equip;
 import client.inventory.Item;
 import client.inventory.MapleInventoryType;
 import constants.ItemConstants;
 import java.awt.Point;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import tools.packet.InventoryPacket;

 public class MapleMapItem
   extends MapleMapObject
 {
   protected final int character_ownerid;
   protected final boolean playerDrop;
/*  19 */   private final ReentrantLock lock = new ReentrantLock();
   protected Item item;
   protected MapleMapObject dropper;
/*  22 */   protected int meso = 0;
/*  23 */   protected int questid = -1;
   protected byte type;
   protected boolean pickedUp = false;
   protected boolean randDrop = false;
/*  27 */   protected long nextExpiry = 0L; protected long nextFFA = 0L;
/*  28 */   private int skill = 0;
/*  29 */   private int delay = 0;
   private Point dropFrom;
/*  31 */   private byte enterType = 1;
/*  32 */   private short fallingVY = 0;
   private byte makeType;

   public MapleMapItem(Item item, Point position, MapleMapObject dropper, MapleCharacter owner, byte type, boolean playerDrop) {
/*  36 */     setPosition(position);
/*  37 */     this.item = item;
/*  38 */     this.dropper = dropper;
/*  39 */     this.character_ownerid = owner.getId();
/*  40 */     this.type = type;
/*  41 */     this.playerDrop = playerDrop;
   }

   public MapleMapItem(Item item, Point position, MapleMapObject dropper, MapleCharacter owner, byte type, boolean playerDrop, int questid) {
/*  45 */     setPosition(position);
/*  46 */     this.item = item;
/*  47 */     this.dropper = dropper;
/*  48 */     this.character_ownerid = owner.getId();
/*  49 */     this.type = type;
/*  50 */     this.playerDrop = playerDrop;
/*  51 */     this.questid = questid;
   }

   public MapleMapItem(int meso, Point position, MapleMapObject dropper, MapleCharacter owner, byte type, boolean playerDrop) {
/*  55 */     setPosition(position);
/*  56 */     this.item = null;
/*  57 */     this.dropper = dropper;
/*  58 */     this.character_ownerid = owner.getId();
/*  59 */     this.meso = meso;
/*  60 */     this.type = type;
/*  61 */     this.playerDrop = playerDrop;
   }

   public MapleMapItem(Point position, Item item) {
/*  65 */     setPosition(position);
/*  66 */     this.item = item;
/*  67 */     this.character_ownerid = 0;
/*  68 */     this.type = 2;
/*  69 */     this.playerDrop = false;
/*  70 */     this.randDrop = true;
   }

   public MapleMapItem(Item item, Point position, int owner, byte type, boolean playerDrop, int questid) {
/*  74 */     setPosition(position);
/*  75 */     this.item = item;
/*  76 */     this.character_ownerid = owner;
/*  77 */     this.type = type;
/*  78 */     this.playerDrop = playerDrop;
/*  79 */     this.questid = questid;
   }

   public Item getItem() {
/*  83 */     return this.item;
   }

   public void setItem(Item z) {
/*  87 */     this.item = z;
   }

   public int getQuest() {
/*  91 */     return this.questid;
   }

   public int getItemId() {
/*  95 */     if (getMeso() > 0) {
/*  96 */       return this.meso;
     }
/*  98 */     return this.item.getItemId();
   }

   public MapleMapObject getDropper() {
/* 102 */     return this.dropper;
   }

   public int getOwner() {
/* 106 */     return this.character_ownerid;
   }

   public int getMeso() {
/* 110 */     return this.meso;
   }

   public boolean isPlayerDrop() {
/* 114 */     return this.playerDrop;
   }

   public boolean isPickedUp() {
/* 118 */     return this.pickedUp;
   }

   public void setPickedUp(boolean pickedUp) {
/* 122 */     this.pickedUp = pickedUp;
   }

   public byte getDropType() {
/* 126 */     return this.type;
   }

   public void setDropType(byte z) {
/* 130 */     this.type = z;
   }

   public boolean isRandDrop() {
/* 134 */     return this.randDrop;
   }


   public MapleMapObjectType getType() {
/* 139 */     return MapleMapObjectType.ITEM;
   }


   public void sendSpawnData(MapleClient client) {
/* 144 */     if (this.questid <= 0 || (client.getPlayer().getQuestStatus(this.questid) == 1 && client.getPlayer().needQuestItem(this.questid, this.item.getItemId()))) {
/* 145 */       client.announce(InventoryPacket.dropItemFromMapObject(this, getPosition(), getTruePosition(), (byte)2));
     }
   }


   public void sendDestroyData(MapleClient client) {
/* 151 */     client.announce(InventoryPacket.removeItemFromMap(getObjectId(), 1, 0));
   }

   public Lock getLock() {
/* 155 */     return this.lock;
   }

   public void registerExpire(long time) {
/* 159 */     this.nextExpiry = System.currentTimeMillis() + time;
   }

   public void registerFFA(long time) {
/* 163 */     this.nextFFA = System.currentTimeMillis() + time;
   }

   public boolean shouldExpire(long now) {
/* 167 */     return (!this.pickedUp && this.nextExpiry > 0L && this.nextExpiry < now);
   }

   public boolean shouldFFA(long now) {
/* 171 */     return (!this.pickedUp && this.type < 2 && this.nextFFA > 0L && this.nextFFA < now);
   }

   public boolean hasFFA() {
/* 175 */     return (this.nextFFA > 0L);
   }

   public void expire(MapleMap map) {
/* 179 */     this.pickedUp = true;
/* 180 */     map.broadcastMessage(InventoryPacket.removeItemFromMap(getObjectId(), 0, 0));
/* 181 */     map.removeMapObject(this);
   }

   public int getState() {
/* 185 */     if (getMeso() > 0) {
/* 186 */       return 0;
     }
/* 188 */     if (ItemConstants.getInventoryType(this.item.getItemId()) != MapleInventoryType.EQUIP) {
/* 189 */       return 0;
     }
/* 191 */     Equip equip = (Equip)this.item;
/* 192 */     int state = equip.getState(false);
/* 193 */     int addstate = equip.getState(true);
/* 194 */     if (state <= 0 || state >= 17) {
/* 195 */       state -= 16; state = (state < 0) ? 0 : state;
     }
/* 197 */     if (addstate <= 0 || addstate >= 17) {
/* 198 */       addstate -= 16; addstate = (addstate < 0) ? 0 : addstate;
     }
/* 200 */     return (state > addstate) ? state : addstate;
   }

   public int getSkill() {
/* 204 */     return this.skill;
   }

   public void setSkill(int skill) {
/* 208 */     this.skill = skill;
   }

   public int getDelay() {
/* 212 */     return this.delay;
   }

   public void setDelay(int delay) {
/* 216 */     this.delay = delay;
   }

   public Point getDropFrom() {
/* 220 */     return this.dropFrom;
   }

   public void setDropFrom(Point dropFrom) {
/* 224 */     this.dropFrom = dropFrom;
   }

   public byte getEnterType() {
/* 228 */     return this.enterType;
   }

   public void setEnterType(byte enterType) {
/* 232 */     this.enterType = enterType;
   }

   public short getFallingVY() {
/* 236 */     return this.fallingVY;
   }

   public void setFallingVY(short fallingVY) {
/* 240 */     this.fallingVY = fallingVY;
   }

   public byte getMakeType() {
/* 244 */     return this.makeType;
   }

   public void setMakeType(byte makeType) {
/* 248 */     this.makeType = makeType;
   }
 }


/* Location:              C:\PGX\Server.jar!\server\maps\MapleMapItem.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */